Skip to content

Commit 3eebdd8

Browse files
committed
#34 Don't trigger a pipe if already triggered.
1 parent 461fbf5 commit 3eebdd8

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

Source/aeolus/division.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,9 @@ bool Division::triggerVoicesForStop(int stopIndex, int note)
609609
{
610610
jassert(isPositiveAndBelow(stopIndex, _stops.size()));
611611

612+
if (isAlreadyVoiced(stopIndex, note))
613+
return true;
614+
612615
const auto& stop = _stops[stopIndex];
613616

614617
if (!stop.isEnabled())
@@ -640,4 +643,19 @@ bool Division::triggerVoicesForStop(int stopIndex, int note)
640643
return voiceTriggered;
641644
}
642645

646+
bool Division::isAlreadyVoiced(int stopIndex, int note)
647+
{
648+
auto* voice = _activeVoices.first();
649+
650+
while (voice != nullptr) {
651+
if (voice->isActive() && voice->stopIndex() == stopIndex && voice->isForNote(note)) {
652+
return true;
653+
}
654+
655+
voice = voice->next();
656+
}
657+
658+
return false;
659+
}
660+
643661
AEOLUS_NAMESPACE_END

Source/aeolus/division.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ class Division
166166

167167
bool triggerVoicesForStop(int stopIndex, int note);
168168

169+
bool isAlreadyVoiced(int stopIndex, int node);
170+
169171
Engine& _engine;
170172

171173
juce::String _name; ///< The division name.

Source/aeolus/voice.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Voice : public ListItem<Voice>
6161
private:
6262
Engine& _engine;
6363
Pipewave::State _state; ///< Pipe state associated with this voice.
64-
64+
6565
/// Index of the stop associated with this voice.
6666
/// This is used to tell which stops are voiced.
6767
int _stopIndex;
@@ -80,7 +80,7 @@ class Voice : public ListItem<Voice>
8080

8181
/// Stereo spatial modeller.
8282
dsp::SpatialSource _spatialSource;
83-
83+
8484
/// Counter to account for the delayed sound before recycling the voice.
8585
size_t _postReleaseCounter;
8686
};

0 commit comments

Comments
 (0)