Skip to content

Commit 859f79c

Browse files
Also update avs when state is Armed
We need to update the avs from avsHistory in two cases : * we just looped, which means currentIndex == minIndex * we moved the cursor manually and called setCurrentIndex, which means we are in Armed state
1 parent a9378fe commit 859f79c

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/include/impl/SequencePerformer.h

+12-12
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ class SequencePerformer : public AbstractPerformer {
8787
}
8888
}
8989

90+
void prepareLocalState() {
91+
createAvsHistoryFromScore();
92+
setLoopIndices(0, (score.size() == 0) ? 0 : (score.size() - 1));
93+
setCurrentIndex(0);
94+
}
95+
9096
void mergeAvsStates(
9197
std::map<noteKey, std::uint8_t>& target,
9298
const std::map<noteKey, std::uint8_t> source
@@ -138,22 +144,22 @@ class SequencePerformer : public AbstractPerformer {
138144
return res; // will be empty if currentIndex == score.size()
139145
}
140146

141-
// set to Playing after call to getNextIndex which checks currentState value
142-
if (currentState == State::Armed) {
143-
currentState = State::Playing;
144-
}
145-
146147
auto activeNotes = avs.getTriggerCountMap();
147148

148149
// if we are about to play first event in loop, we set avs to take upcoming
149150
// note offs from unplayed note ons into account
150-
if (currentIndex == minIndex) {
151+
if (currentIndex == minIndex || currentState == State::Armed) {
151152
// merge avs state snapshot with current avs state
152153
auto avsState = avsHistory[currentIndex];
153154
mergeAvsStates(avsState, activeNotes);
154155
avs.setTriggerCountMap(avsState);
155156
}
156157

158+
// set to Playing after call to getNextIndex which checks currentState value
159+
if (currentState == State::Armed) {
160+
currentState = State::Playing;
161+
}
162+
157163
// if we are getting the last set pair, we might have some pending endings
158164
// so we make sure to end them all in ending set
159165
if (currentIndex == maxIndex) {
@@ -173,12 +179,6 @@ class SequencePerformer : public AbstractPerformer {
173179
return res;
174180
}
175181

176-
void prepareLocalState(){
177-
createAvsHistoryFromScore();
178-
setLoopIndices(0, (score.size() == 0) ? 0 : (score.size() - 1));
179-
setCurrentIndex(0);
180-
}
181-
182182
public:
183183
SequencePerformer() :
184184
AbstractPerformer(), score(Chronology<noteData, std::vector>()),

0 commit comments

Comments
 (0)