summaryrefslogtreecommitdiff
path: root/src/drumgizmo.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/drumgizmo.cc')
-rw-r--r--src/drumgizmo.cc23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc
index 5d7de70..2f2232c 100644
--- a/src/drumgizmo.cc
+++ b/src/drumgizmo.cc
@@ -49,6 +49,7 @@ DrumGizmo::DrumGizmo(AudioOutputEngine *o, AudioInputEngine *i)
: MessageReceiver(MSGRCV_ENGINE),
loader(), oe(o), ie(i)
{
+ is_stopping = false;
}
DrumGizmo::~DrumGizmo()
@@ -86,10 +87,8 @@ bool DrumGizmo::loadkit(std::string file)
return true;
}
-bool DrumGizmo::init(bool preload)
+bool DrumGizmo::init()
{
- (void)preload;
-
if(!ie->init(kit.instruments)) return false;
if(!oe->init(kit.channels)) return false;
@@ -257,7 +256,23 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples)
}
if(evs[e].type == TYPE_STOP) {
- return false;
+ is_stopping = true;
+ }
+
+ if(is_stopping) {
+ // Count the number of active events.
+ int num_active_events = 0;
+ Channels::iterator j = kit.channels.begin();
+ while(j != kit.channels.end()) {
+ Channel &ch = *j;
+ num_active_events += activeevents[ch.num].size();
+ j++;
+ }
+
+ if(num_active_events == 0) {
+ // No more active events - now we can stop the engine.
+ return false;
+ }
}
}