From 6442f316d4fa49847d19a3cb6b27dff45f588881 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 3 Mar 2014 13:35:09 +0100 Subject: detect VST midi-in/midi-out ports separately. --- libs/ardour/plugin_manager.cc | 6 ++++-- libs/ardour/vst_info_file.cc | 31 ++++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 5 deletions(-) (limited to 'libs') diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc index b3117fcbb6..72df671928 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -713,7 +713,8 @@ PluginManager::windows_vst_discover (string path, bool cache_only) info->index = 0; info->n_inputs.set_audio (finfo->numInputs); info->n_outputs.set_audio (finfo->numOutputs); - info->n_inputs.set_midi (finfo->wantMidi ? 1 : 0); + info->n_inputs.set_midi ((finfo->wantMidi&1) ? 1 : 0); + info->n_outputs.set_midi ((finfo->wantMidi&2) ? 1 : 0); info->type = ARDOUR::Windows_VST; // TODO: check dup-IDs (lxvst AND windows vst) @@ -833,7 +834,8 @@ PluginManager::lxvst_discover (string path, bool cache_only) info->index = 0; info->n_inputs.set_audio (finfo->numInputs); info->n_outputs.set_audio (finfo->numOutputs); - info->n_inputs.set_midi (finfo->wantMidi ? 1 : 0); + info->n_inputs.set_midi ((finfo->wantMidi&1) ? 1 : 0); + info->n_outputs.set_midi ((finfo->wantMidi&2) ? 1 : 0); info->type = ARDOUR::LXVST; /* Make sure we don't find the same plugin in more than one place along diff --git a/libs/ardour/vst_info_file.cc b/libs/ardour/vst_info_file.cc index e6ab197fd0..d7b83fcab8 100644 --- a/libs/ardour/vst_info_file.cc +++ b/libs/ardour/vst_info_file.cc @@ -147,6 +147,11 @@ vstfx_load_info_block(FILE* fp, VSTInfo *info) if (read_int (fp, &info->hasEditor)) return false; if (read_int (fp, &info->canProcessReplacing)) return false; + /* backwards compatibility with old .fsi files */ + if (info->wantMidi == -1) { + info->wantMidi = 1; + } + if ((info->ParamNames = (char **) malloc(sizeof(char*)*info->numParams)) == 0) { return false; } @@ -434,7 +439,7 @@ vstfx_infofile_for_write (const char* dllpath) } static -int vstfx_can_midi (VSTState* vstfx) +bool vstfx_midi_input (VSTState* vstfx) { AEffect* plugin = vstfx->plugin; @@ -444,7 +449,27 @@ int vstfx_can_midi (VSTState* vstfx) /* should we send it VST events (i.e. MIDI) */ if ((plugin->flags & effFlagsIsSynth) || (plugin->dispatcher (plugin, effCanDo, 0, 0,(void*) "receiveVstEvents", 0.0f) > 0)) { - return -1; + return true; + } + } + + return false; +} + +static +bool vstfx_midi_output (VSTState* vstfx) +{ + AEffect* plugin = vstfx->plugin; + + int const vst_version = plugin->dispatcher (plugin, effGetVstVersion, 0, 0, 0, 0.0f); + + if (vst_version >= 2) { + /* should we send it VST events (i.e. MIDI) */ + + if ( (plugin->dispatcher (plugin, effCanDo, 0, 0,(void*) "sendVstEvents", 0.0f) > 0) + || (plugin->dispatcher (plugin, effCanDo, 0, 0,(void*) "sendVstMidiEvent", 0.0f) > 0) + ) { + return true; } } @@ -507,7 +532,7 @@ vstfx_parse_vst_state (VSTState* vstfx) info->numInputs = plugin->numInputs; info->numOutputs = plugin->numOutputs; info->numParams = plugin->numParams; - info->wantMidi = vstfx_can_midi(vstfx); + info->wantMidi = (vstfx_midi_input(vstfx) ? 1 : 0) | (vstfx_midi_output(vstfx) ? 2 : 0); info->hasEditor = plugin->flags & effFlagsHasEditor ? true : false; info->canProcessReplacing = plugin->flags & effFlagsCanReplacing ? true : false; info->ParamNames = (char **) malloc(sizeof(char*)*info->numParams); -- cgit v1.2.3