Move some code around to help remote tool later
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
76cdce063c
commit
058ad891d2
11 changed files with 747 additions and 198 deletions
|
@ -59,6 +59,115 @@
|
|||
|
||||
const std::string CARDINAL_VERSION = "22.12";
|
||||
|
||||
START_NAMESPACE_DISTRHO
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------
|
||||
|
||||
void handleHostParameterDrag(const CardinalPluginContext* pcontext, uint index, bool started)
|
||||
{
|
||||
DISTRHO_SAFE_ASSERT_RETURN(pcontext->ui != nullptr,);
|
||||
|
||||
if (started)
|
||||
{
|
||||
pcontext->ui->editParameter(index, true);
|
||||
pcontext->ui->setParameterValue(index, pcontext->parameters[index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
pcontext->ui->editParameter(index, false);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
bool CardinalPluginContext::addIdleCallback(IdleCallback* const cb) const
|
||||
{
|
||||
if (ui == nullptr)
|
||||
return false;
|
||||
|
||||
ui->addIdleCallback(cb);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CardinalPluginContext::removeIdleCallback(IdleCallback* const cb) const
|
||||
{
|
||||
if (ui == nullptr)
|
||||
return;
|
||||
|
||||
ui->removeIdleCallback(cb);
|
||||
}
|
||||
|
||||
void CardinalPluginContext::writeMidiMessage(const rack::midi::Message& message, const uint8_t channel)
|
||||
{
|
||||
if (bypassed)
|
||||
return;
|
||||
|
||||
const size_t size = message.bytes.size();
|
||||
DISTRHO_SAFE_ASSERT_RETURN(size > 0,);
|
||||
DISTRHO_SAFE_ASSERT_RETURN(message.frame >= 0,);
|
||||
|
||||
MidiEvent event;
|
||||
event.frame = message.frame;
|
||||
|
||||
switch (message.bytes[0] & 0xF0)
|
||||
{
|
||||
case 0x80:
|
||||
case 0x90:
|
||||
case 0xA0:
|
||||
case 0xB0:
|
||||
case 0xE0:
|
||||
event.size = 3;
|
||||
break;
|
||||
case 0xC0:
|
||||
case 0xD0:
|
||||
event.size = 2;
|
||||
break;
|
||||
case 0xF0:
|
||||
switch (message.bytes[0] & 0x0F)
|
||||
{
|
||||
case 0x0:
|
||||
case 0x4:
|
||||
case 0x5:
|
||||
case 0x7:
|
||||
case 0x9:
|
||||
case 0xD:
|
||||
// unsupported
|
||||
return;
|
||||
case 0x1:
|
||||
case 0x2:
|
||||
case 0x3:
|
||||
case 0xE:
|
||||
event.size = 3;
|
||||
break;
|
||||
case 0x6:
|
||||
case 0x8:
|
||||
case 0xA:
|
||||
case 0xB:
|
||||
case 0xC:
|
||||
case 0xF:
|
||||
event.size = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// invalid
|
||||
return;
|
||||
}
|
||||
|
||||
DISTRHO_SAFE_ASSERT_RETURN(size >= event.size,);
|
||||
|
||||
std::memcpy(event.data, message.bytes.data(), event.size);
|
||||
|
||||
if (channel != 0 && event.data[0] < 0xF0)
|
||||
event.data[0] |= channel & 0x0F;
|
||||
|
||||
plugin->writeMidiEvent(event);
|
||||
}
|
||||
|
||||
END_NAMESPACE_DISTRHO
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace rack {
|
||||
|
||||
bool isStandalone()
|
||||
|
@ -118,6 +227,8 @@ std::string homeDir()
|
|||
|
||||
} // namespace rack
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
namespace patchUtils
|
||||
{
|
||||
|
||||
|
@ -289,6 +400,8 @@ void openBrowser(const std::string& url)
|
|||
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void async_dialog_filebrowser(const bool saving,
|
||||
const char* const defaultName,
|
||||
const char* const startDir,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue