Create a virtual base class for PluginInsert

This in in preparation for IO-Plug GUI support.
This commit is contained in:
Robin Gareus 2022-04-05 04:46:35 +02:00
parent f9d80c32d6
commit 74a673ce17
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
4 changed files with 92 additions and 2 deletions

View File

@ -0,0 +1,71 @@
/*
* Copyright (C) 2022 Robin Gareus <robin@gareus.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef _ardour_plugin_insert_base_h_
#define _ardour_plugin_insert_base_h_
#include "pbd/destructible.h"
#include "evoral/ControlSet.h"
#include "ardour/ardour.h"
#include "ardour/plugin.h"
#include "ardour/plugin_types.h"
namespace ARDOUR {
class Session;
class ReadOnlyControl;
class Route;
class Plugin;
class LIBARDOUR_API PlugInsertBase : virtual public Evoral::ControlSet, virtual public PBD::Destructible
{
public:
virtual ~PlugInsertBase () {}
virtual uint32_t get_count () const = 0;
virtual boost::shared_ptr<Plugin> plugin (uint32_t num = 0) const = 0;
virtual PluginType type () const = 0;
enum UIElements : std::uint8_t {
NoGUIToolbar = 0x00,
BypassEnable = 0x01,
PluginPreset = 0x02,
MIDIKeyboard = 0x04,
AllUIElements = 0x0f
};
virtual UIElements ui_elements () const = 0;
virtual bool write_immediate_event (Evoral::EventType event_type, size_t size, const uint8_t* buf) = 0;
virtual bool load_preset (Plugin::PresetRecord) = 0;
virtual boost::shared_ptr<ReadOnlyControl> control_output (uint32_t) const = 0;
virtual bool can_reset_all_parameters () = 0;
virtual bool reset_parameters_to_default () = 0;
virtual bool provides_stats () const = 0;
virtual bool get_stats (PBD::microseconds_t&, PBD::microseconds_t&, double&, double&) const = 0;
virtual void clear_stats () = 0;
};
} // namespace ARDOUR
#endif

View File

@ -41,6 +41,7 @@
#include "ardour/types.h"
#include "ardour/parameter_descriptor.h"
#include "ardour/plugin.h"
#include "ardour/plug_insert_base.h"
#include "ardour/processor.h"
#include "ardour/readonly_control.h"
#include "ardour/sidechain.h"
@ -56,7 +57,7 @@ class Plugin;
/** Plugin inserts: send data through a plugin
*/
class LIBARDOUR_API PluginInsert : public Processor
class LIBARDOUR_API PluginInsert : public Processor, public PlugInsertBase
{
public:
PluginInsert (Session&, Temporal::TimeDomain td, boost::shared_ptr<Plugin> = boost::shared_ptr<Plugin>());
@ -123,6 +124,8 @@ public:
bool is_channelstrip () const;
UIElements ui_elements () const;
void set_input_map (uint32_t, ChanMapping);
void set_output_map (uint32_t, ChanMapping);
void set_thru_map (ChanMapping);
@ -360,7 +363,6 @@ private:
bool _strict_io;
bool _custom_cfg;
bool _maps_from_state;
bool _mapping_changed;
Match private_can_support_io_configuration (ChanCount const &, ChanCount &) const;
Match internal_can_support_io_configuration (ChanCount const &, ChanCount &) const;

View File

@ -155,6 +155,7 @@ Auditioner::load_synth ()
if (asynth) {
ProcessorStreams ps;
asynth->set_owner (this);
if (add_processor (asynth, PreFader, &ps, true)) {
error << _("Failed to load synth for MIDI-Audition.") << endmsg;
}

View File

@ -459,6 +459,19 @@ PluginInsert::is_instrument() const
return (pip->is_instrument ());
}
PlugInsertBase::UIElements
PluginInsert::ui_elements () const
{
if (owner () == (ARDOUR::SessionObject*)(_session.the_auditioner().get())) {
return NoGUIToolbar;
}
UIElements rv = AllUIElements;
if (!is_instrument()) {
rv = static_cast<PlugInsertBase::UIElements> (static_cast <std::uint8_t>(rv) & ~static_cast<std::uint8_t> (PlugInsertBase::MIDIKeyboard));
}
return rv;
}
bool
PluginInsert::has_output_presets (ChanCount in, ChanCount out)
{
@ -3387,6 +3400,9 @@ PluginInsert::provides_stats () const
return false;
}
#endif
if (owner () == (ARDOUR::SessionObject*)(_session.the_auditioner().get())) {
return false;
}
return true;
}