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;
|
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,
|
void run(const float** const inputs, float** const outputs, const uint32_t frames,
|
||||||
const MidiEvent* const midiEvents, const uint32_t midiEventCount) override
|
const MidiEvent* const midiEvents, const uint32_t midiEventCount) override
|
||||||
{
|
{
|
||||||
|
@ -874,6 +883,32 @@ protected:
|
||||||
|
|
||||||
{
|
{
|
||||||
const TimePosition& timePos(getTimePosition());
|
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->playing = timePos.playing;
|
||||||
context->bbtValid = timePos.bbt.valid;
|
context->bbtValid = timePos.bbt.valid;
|
||||||
context->frame = timePos.frame;
|
context->frame = timePos.frame;
|
||||||
|
@ -896,9 +931,6 @@ protected:
|
||||||
context->tickClock = std::fmod(timePos.bbt.tick, context->ticksPerClock);
|
context->tickClock = std::fmod(timePos.bbt.tick, context->ticksPerClock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timePos.playing && fPreviousFrame + frames != timePos.frame)
|
|
||||||
context->reset = true;
|
|
||||||
|
|
||||||
fPreviousFrame = timePos.frame;
|
fPreviousFrame = timePos.frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,18 @@ struct CardinalMidiInputDevice : rack::midi::InputDevice
|
||||||
return "Cardinal";
|
return "Cardinal";
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleMessagesFromHost(const MidiEvent* const midiEvents, const uint32_t midiEventCount)
|
inline void handleSingleSimpleMessageFromHost(const MidiEvent& midiEvent)
|
||||||
|
{
|
||||||
|
if (subscribed.size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
msg.frame = midiEvent.frame;
|
||||||
|
std::memcpy(msg.bytes.data(), midiEvent.data, midiEvent.size);
|
||||||
|
|
||||||
|
onMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void handleMessagesFromHost(const MidiEvent* const midiEvents, const uint32_t midiEventCount)
|
||||||
{
|
{
|
||||||
if (subscribed.size() == 0)
|
if (subscribed.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue