diff --git a/dpf b/dpf index ea7545a..7a056bb 160000 --- a/dpf +++ b/dpf @@ -1 +1 @@ -Subproject commit ea7545a13ab9793b5608b13a82f1ad9cf9ec5e98 +Subproject commit 7a056bbcf84f9437d7a00a5659be5bb6008bfe1d diff --git a/plugins/Kars/DistrhoPluginKars.cpp b/plugins/Kars/DistrhoPluginKars.cpp index 910a4dc..b3d1b43 100644 --- a/plugins/Kars/DistrhoPluginKars.cpp +++ b/plugins/Kars/DistrhoPluginKars.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Kars Plugin, based on karplong by Chris Cannam. - * Copyright (C) 2015 Filipe Coelho + * Copyright (C) 2015-2019 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -158,7 +158,8 @@ public: midiEvents(m), midiEventCount(0), remainingFrames(f), - remainingMidiEventCount(mc) {} + remainingMidiEventCount(mc), + totalFramesUsed(0) {} /** Process a batch of events untill no more are available. @@ -166,41 +167,76 @@ public: */ bool nextEvent() { - if (remainingMidiEventCount == 0) + // nothing else to do + if (remainingFrames == 0) + return false; + + // initial setup, need to find first MIDI event + if (totalFramesUsed == 0) { - if (remainingFrames == 0) - return false; + // no MIDI events at all in this process cycle + if (remainingMidiEventCount == 0) + { + frames = remainingFrames; + remainingFrames = 0; + totalFramesUsed += frames; + return true; + } + // render audio until first midi event, if needed + if (const uint32_t firstEventFrame = midiEvents[0].frame) + { + frames = midiEvents[0].frame; + remainingFrames -= frames; + totalFramesUsed += frames; + return true; + } + } + else + { for (uint32_t i=0; i(midiEvents); + for (uint32_t i=0; i < midiEventCount; ++i) + rwEvents[i].frame -= totalFramesUsed; + } + + frames = remainingFrames - firstEventFrame; remainingFrames -= frames; remainingMidiEventCount -= midiEventCount; + totalFramesUsed += frames; return true; } @@ -208,6 +244,7 @@ private: /** @internal */ uint32_t remainingFrames; uint32_t remainingMidiEventCount; + uint32_t totalFramesUsed; }; void DistrhoPluginKars::run(const float**, float** outputs, uint32_t frames, const MidiEvent* midiEvents, uint32_t midiEventCount) @@ -254,9 +291,9 @@ void DistrhoPluginKars::run(const float**, float** outputs, uint32_t frames, con if (fNotes[i].on != kNoteNull) addSamples(out, i, amsh.frames); } - } - fBlockStart += frames; + fBlockStart += amsh.frames; + } } void DistrhoPluginKars::addSamples(float* out, int voice, uint32_t frames) diff --git a/plugins/Kars/DistrhoPluginKars.hpp b/plugins/Kars/DistrhoPluginKars.hpp index 605cc6d..e7010d3 100644 --- a/plugins/Kars/DistrhoPluginKars.hpp +++ b/plugins/Kars/DistrhoPluginKars.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Kars Plugin, based on karplong by Chris Cannam. - * Copyright (C) 2015 Filipe Coelho + * Copyright (C) 2015-2019 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -70,7 +70,7 @@ protected: uint32_t getVersion() const noexcept override { - return d_version(1, 0, 0); + return d_version(1, 1, 0); } int64_t getUniqueId() const noexcept override