Browse Source

Fix MIDI pattern missing notes at the edges, improve MIDI performance

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.3.0-RC1
falkTX 4 years ago
parent
commit
64ee3bea0b
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 12 additions and 8 deletions
  1. +7
    -5
      source/native-plugins/midi-base.hpp
  2. +5
    -3
      source/native-plugins/midi-pattern.cpp

+ 7
- 5
source/native-plugins/midi-base.hpp View File

@@ -231,7 +231,7 @@ public:
play(static_cast<long double>(timePosFrame), static_cast<double>(frames));
}

void play(long double timePosFrame, const double frames)
void play(long double timePosFrame, const double frames, const double offset = 0.0)
{
if (! fMutex.tryLock())
return;
@@ -244,12 +244,14 @@ public:
const RawMidiEvent* const rawMidiEvent(it.getValue(nullptr));
CARLA_SAFE_ASSERT_CONTINUE(rawMidiEvent != nullptr);

if (timePosFrame > rawMidiEvent->time)
continue;
if (timePosFrame + frames <= rawMidiEvent->time)
if (rawMidiEvent->time < timePosFrame)
continue;
if (static_cast<long double>(rawMidiEvent->time) > timePosFrame + frames)
break;

kPlayer->writeMidiEvent(fMidiPort, static_cast<long double>(rawMidiEvent->time)-timePosFrame, rawMidiEvent);
kPlayer->writeMidiEvent(fMidiPort,
static_cast<long double>(rawMidiEvent->time) - timePosFrame + offset,
rawMidiEvent);
}

fMutex.unlock();


+ 5
- 3
source/native-plugins/midi-pattern.cpp View File

@@ -263,8 +263,9 @@ protected:
}
else
{
fMidiOut.play(loopedPlayPos, fMaxTicks-loopedPlayPos);
fMidiOut.play(0.0, loopedEndPos);
const double diff = fMaxTicks - loopedPlayPos;
fMidiOut.play(loopedPlayPos, diff);
fMidiOut.play(0.0, loopedEndPos, diff);
}
}
}
@@ -353,7 +354,8 @@ protected:
midiEvent.size = event->size;

#ifdef DEBUG
carla_stdout("Playing at %f :: %03X:%03i:%03i",
carla_stdout("Playing at %f|%u :: %03X:%03i:%03i",
midiEvent.time,
static_cast<double>(midiEvent.time)*fTicksPerFrame,
midiEvent.data[0], midiEvent.data[1], midiEvent.data[2]);
#endif


Loading…
Cancel
Save