X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=libs%2Fardour%2Fvst_plugin.cc;h=cbd88877cd8bcb033de9858471bd3ddc2c173599;hb=cbef72b8a13;hp=9832b81b720d69367345e06e6d3b50f945e107a9;hpb=8e25b4d193fb4fb9efbf7a7145d27879dcd668be;p=ardour.git diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc index 9832b81b72..cbd88877cd 100644 --- a/libs/ardour/vst_plugin.cc +++ b/libs/ardour/vst_plugin.cc @@ -139,6 +139,31 @@ VSTPlugin::set_block_size (pframes_t nframes) return 0; } +bool +VSTPlugin::requires_fixed_sized_buffers () const +{ + /* This controls if Ardour will split the plugin's run() + * on automation events in order to pass sample-accurate automation + * via standard control-ports. + * + * When returning true Ardour will *not* sub-divide the process-cycle. + * Automation events that happen between cycle-start and cycle-end will be + * ignored (ctrl values are interpolated to cycle-start). + * + * Note: This does not guarantee a fixed block-size. + * e.g The process cycle may be split when looping, also + * the period-size may change any time: see set_block_size() + */ + if (get_info()->n_inputs.n_midi() > 0) { + /* we don't yet implement midi buffer offsets (for split cycles). + * Also session_vst callbacls uses _session.transport_sample() directly + * (for BBT) which is not offset for plugin cycle split. + */ + return true; + } + return false; +} + float VSTPlugin::default_value (uint32_t which) { @@ -540,8 +565,6 @@ VSTPlugin::do_save_preset (string name) sha1_result_hash (&s, hash); string const uri = string_compose (X_("VST:%1:x%2"), unique_id (), hash); - string const str_ver = std::to_string (version ()); - string const num_params = std::to_string (parameter_count ()); if (_plugin->flags & 32 /* effFlagsProgramsChunks */) { p = new XMLNode (X_("ChunkPreset")); @@ -550,9 +573,9 @@ VSTPlugin::do_save_preset (string name) } p->set_property (X_("uri"), uri); - p->set_property (X_("version"), str_ver); + p->set_property (X_("version"), version ()); p->set_property (X_("label"), name); - p->set_property (X_("numParams"), num_params); + p->set_property (X_("numParams"), parameter_count ()); if (_plugin->flags & 32) { @@ -648,7 +671,7 @@ VSTPlugin::automatable () const int VSTPlugin::connect_and_run (BufferSet& bufs, samplepos_t start, samplepos_t end, double speed, - ChanMapping in_map, ChanMapping out_map, + ChanMapping const& in_map, ChanMapping const& out_map, pframes_t nframes, samplecnt_t offset) { Plugin::connect_and_run(bufs, start, end, speed, in_map, out_map, nframes, offset); @@ -711,6 +734,7 @@ VSTPlugin::connect_and_run (BufferSet& bufs, VstEvents* v = 0; bool valid = false; const uint32_t buf_index_in = in_map.get(DataType::MIDI, 0, &valid); + /* TODO: apply offset to MIDI buffer and trim at nframes */ if (valid) { v = bufs.get_vst_midi (buf_index_in); } @@ -718,7 +742,8 @@ VSTPlugin::connect_and_run (BufferSet& bufs, const uint32_t buf_index_out = out_map.get(DataType::MIDI, 0, &valid); if (valid) { _midi_out_buf = &bufs.get_midi(buf_index_out); - _midi_out_buf->silence(0, 0); + /* TODO: apply offset to MIDI buffer and trim at nframes */ + _midi_out_buf->silence(nframes, offset); } else { _midi_out_buf = 0; } @@ -815,7 +840,8 @@ VSTPlugin::find_presets () int const vst_version = _plugin->dispatcher (_plugin, effGetVstVersion, 0, 0, NULL, 0); for (int i = 0; i < _plugin->numPrograms; ++i) { - PresetRecord r (string_compose (X_("VST:%1:%2"), unique_id (), i), "", false); + + PresetRecord r (string_compose (X_("VST:%1:%2"), unique_id (), std::setw(4), std::setfill('0'), i), "", false); if (vst_version >= 2) { char buf[256];