Implement START/STOP/CONT messages for midi-cv usage
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
52d1bffd5c
commit
2745482670
2 changed files with 47 additions and 4 deletions
|
@ -866,6 +866,15 @@ protected:
|
|||
fAudioBufferIn = nullptr;
|
||||
}
|
||||
|
||||
inline void sendSingleSimpleMidiMessage(const MidiEvent& midiEvent)
|
||||
{
|
||||
if (CardinalMidiInputDevice** inputs = fCurrentMidiInputs)
|
||||
{
|
||||
for (;*inputs != nullptr; ++inputs)
|
||||
(*inputs)->handleSingleSimpleMessageFromHost(midiEvent);
|
||||
}
|
||||
}
|
||||
|
||||
void run(const float** const inputs, float** const outputs, const uint32_t frames,
|
||||
const MidiEvent* const midiEvents, const uint32_t midiEventCount) override
|
||||
{
|
||||
|
@ -874,6 +883,32 @@ protected:
|
|||
|
||||
{
|
||||
const TimePosition& timePos(getTimePosition());
|
||||
|
||||
MidiEvent singleTimeMidiEvent = { 0, 1, { 0, 0, 0, 0 }, nullptr };
|
||||
|
||||
if (timePos.playing)
|
||||
{
|
||||
if (timePos.frame == 0 || fPreviousFrame + frames != timePos.frame)
|
||||
context->reset = true;
|
||||
|
||||
if (! context->playing)
|
||||
{
|
||||
if (timePos.frame == 0)
|
||||
{
|
||||
singleTimeMidiEvent.data[0] = 0xFA;
|
||||
sendSingleSimpleMidiMessage(singleTimeMidiEvent);
|
||||
}
|
||||
|
||||
singleTimeMidiEvent.data[0] = 0xFB;
|
||||
sendSingleSimpleMidiMessage(singleTimeMidiEvent);
|
||||
}
|
||||
}
|
||||
else if (context->playing)
|
||||
{
|
||||
singleTimeMidiEvent.data[0] = 0xFC;
|
||||
sendSingleSimpleMidiMessage(singleTimeMidiEvent);
|
||||
}
|
||||
|
||||
context->playing = timePos.playing;
|
||||
context->bbtValid = timePos.bbt.valid;
|
||||
context->frame = timePos.frame;
|
||||
|
@ -896,9 +931,6 @@ protected:
|
|||
context->tickClock = std::fmod(timePos.bbt.tick, context->ticksPerClock);
|
||||
}
|
||||
|
||||
if (timePos.playing && fPreviousFrame + frames != timePos.frame)
|
||||
context->reset = true;
|
||||
|
||||
fPreviousFrame = timePos.frame;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue