diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2015-02-19 18:05:53 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2015-02-19 18:05:53 +0100 |
commit | 7bdc1773013b90d8bf7adcf5907f7e096dd7be6f (patch) | |
tree | 3db301f8f33833226d8d4d732efbcbecb4717881 /src/drumgizmo.cc | |
parent | d38c843e13d411ab822b939a477dc6d6bc7fe5b2 (diff) | |
parent | b16f9d793d6e3e4ab88efff112f2fca30ed87be5 (diff) |
Merge branch 'master' into lv2opt
Diffstat (limited to 'src/drumgizmo.cc')
-rw-r--r-- | src/drumgizmo.cc | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 71043af..6fd454e 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -43,10 +43,13 @@ #include "configuration.h" #include "configparser.h" +#include "nolocale.h" + DrumGizmo::DrumGizmo(AudioOutputEngine *o, AudioInputEngine *i) : MessageReceiver(MSGRCV_ENGINE), loader(), oe(o), ie(i) { + is_stopping = false; } DrumGizmo::~DrumGizmo() @@ -84,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; @@ -255,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; + } } } @@ -409,12 +426,13 @@ void DrumGizmo::getSamples(int ch, int pos, sample_t *s, size_t sz) evt->rampdown--; } + if(evt->rampdown == 0) { + removeevent = true; // Down ramp done. Remove event. + } } if(evt->t >= af->size) { removeevent = true; -// LAZYLOAD: -// loader.reset(af); } } @@ -455,7 +473,7 @@ void DrumGizmo::setSamplerate(int samplerate) std::string float2str(float a) { char buf[256]; - sprintf(buf, "%f", a); + snprintf_nol(buf, sizeof(buf) - 1, "%f", a); return buf; } @@ -467,7 +485,7 @@ std::string bool2str(bool a) float str2float(std::string a) { if(a == "") return 0.0; - return atof(a.c_str()); + return atof_nol(a.c_str()); } std::string DrumGizmo::configString() |