13
0

Add Input Port meters for I/O Pre-Plugin outputs

This commit is contained in:
Robin Gareus 2022-05-17 02:25:23 +02:00
parent cdf3b5209e
commit 5c85695362
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 74 additions and 1 deletions

View File

@ -30,6 +30,7 @@
#include "ardour/latent.h" #include "ardour/latent.h"
#include "ardour/graphnode.h" #include "ardour/graphnode.h"
#include "ardour/plugin.h" #include "ardour/plugin.h"
#include "ardour/port_manager.h"
#include "ardour/session_object.h" #include "ardour/session_object.h"
#include "ardour/plug_insert_base.h" #include "ardour/plug_insert_base.h"
@ -68,6 +69,11 @@ public:
Gtkmm2ext::WindowProxy* window_proxy () const { return _window_proxy; } Gtkmm2ext::WindowProxy* window_proxy () const { return _window_proxy; }
void set_window_proxy (Gtkmm2ext::WindowProxy* wp) { _window_proxy = wp; } void set_window_proxy (Gtkmm2ext::WindowProxy* wp) { _window_proxy = wp; }
PortManager::AudioInputPorts audio_input_ports () const { return _audio_input_ports; }
PortManager::MIDIInputPorts midi_input_ports () const { return _midi_input_ports; }
void reset_input_meters ();
/* Latent */ /* Latent */
samplecnt_t signal_latency () const; samplecnt_t signal_latency () const;
@ -157,10 +163,14 @@ private:
boost::shared_ptr<IO> _input; boost::shared_ptr<IO> _input;
boost::shared_ptr<IO> _output; boost::shared_ptr<IO> _output;
PortManager::AudioInputPorts _audio_input_ports;
PortManager::MIDIInputPorts _midi_input_ports;
Gtkmm2ext::WindowProxy* _window_proxy; Gtkmm2ext::WindowProxy* _window_proxy;
PBD::TimingStats _timing_stats; PBD::TimingStats _timing_stats;
GATOMIC_QUAL gint _stat_reset; GATOMIC_QUAL gint _stat_reset;
GATOMIC_QUAL gint _reset_meters;
}; };
} }

View File

@ -22,6 +22,7 @@
#include "temporal/tempo.h" #include "temporal/tempo.h"
#include "ardour/audioengine.h"
#include "ardour/audio_buffer.h" #include "ardour/audio_buffer.h"
#include "ardour/audio_port.h" #include "ardour/audio_port.h"
#include "ardour/event_type_map.h" #include "ardour/event_type_map.h"
@ -48,6 +49,7 @@ IOPlug::IOPlug (Session& s, boost::shared_ptr<Plugin> p, bool pre)
, _window_proxy (0) , _window_proxy (0)
{ {
g_atomic_int_set (&_stat_reset, 0); g_atomic_int_set (&_stat_reset, 0);
g_atomic_int_set (&_reset_meters, 0);
if (_plugin) { if (_plugin) {
setup (); setup ();
@ -67,7 +69,7 @@ IOPlug::~IOPlug ()
std::string std::string
IOPlug::io_name (std::string const& n) const IOPlug::io_name (std::string const& n) const
{ {
return (string_compose ("%1/%2/%3", _("IO"), _pre ? _("Pre"): _("Post"), n.empty () ? name() : n)); return (string_compose ("%1/%2/%3", _("IO"), _pre ? _("Pre"): _("Post"), n.empty () ? name () : n));
} }
std::string std::string
@ -381,6 +383,38 @@ IOPlug::ensure_io ()
} }
_bufs.ensure_buffers (ChanCount::max (_n_in, _n_out), _session.get_block_size ()); _bufs.ensure_buffers (ChanCount::max (_n_in, _n_out), _session.get_block_size ());
for (uint32_t i = 0; i < _n_in.n_audio (); ++i) {
const auto& pd (_plugin->describe_io_port (DataType::AUDIO, true, i));
std::string const pn = string_compose ("%1 %2 - %3", _("IO"), name (), pd.name);
_input->audio (i)->set_pretty_name (pn);
}
for (uint32_t i = 0; i < _n_in.n_midi (); ++i) {
const auto& pd (_plugin->describe_io_port (DataType::MIDI, true, i));
std::string const pn = string_compose ("%1 %2 - %3", _("IO"), name (), pd.name);
_input->midi (i)->set_pretty_name (pn);
}
for (uint32_t i = 0; i < _n_out.n_audio (); ++i) {
const auto& pd (_plugin->describe_io_port (DataType::AUDIO, false, i));
std::string const pn = string_compose ("%1 %2 - %3", _("IO"), name (), pd.name);
_output->audio (i)->set_pretty_name (pn);
}
for (uint32_t i = 0; i < _n_out.n_midi (); ++i) {
const auto& pd (_plugin->describe_io_port (DataType::MIDI, false, i));
std::string const pn = string_compose ("%1 %2 - %3", _("IO"), name (), pd.name);
_output->midi (i)->set_pretty_name (pn);
}
if (_pre) {
for (uint32_t i = 0; i < _n_out.n_audio (); ++i) {
std::string const& n = AudioEngine::instance ()->make_port_name_non_relative (_output->audio (i)->name ());
_audio_input_ports.insert (make_pair (n, PortManager::AudioInputPort (24288))); // 2^19 ~ 1MB / port
}
for (uint32_t i = 0; i < _n_out.n_midi (); ++i) {
std::string const& n = AudioEngine::instance ()->make_port_name_non_relative (_output->midi (i)->name ());
_midi_input_ports.insert (make_pair (n, PortManager::MIDIInputPort (32)));
}
}
return true; return true;
} }
@ -431,6 +465,28 @@ IOPlug::run (samplepos_t start, pframes_t n_samples)
} }
PortSet& ports (_output->ports()); PortSet& ports (_output->ports());
if (_pre) {
const bool reset = g_atomic_int_compare_and_exchange (&_reset_meters, 1, 0);
samplecnt_t const rate = _session.nominal_sample_rate ();
auto a = _audio_input_ports.begin ();
auto m = _midi_input_ports.begin ();
for (auto p = _bufs.audio_begin (); p != _bufs.audio_end (); ++p, ++a) {
AudioBuffer const& ab (*p);
PortManager::AudioInputPort& ai (a->second);
ai.apply_falloff (n_samples, rate, reset);
ai.process (ab.data (), n_samples, reset);
}
for (auto p = _bufs.midi_begin (); p != _bufs.midi_end (); ++p, ++m) {
PortManager::MIDIInputPort& mi (m->second);
MidiBuffer const& mb (*p);
mi.apply_falloff (n_samples, rate, reset);
for (MidiBuffer::const_iterator i = mb.begin (); i != mb.end (); ++i) {
Evoral::Event<samplepos_t> ev (*i, false);
mi.process_event (ev.buffer (), ev.size ());
}
}
}
for (PortSet::iterator i = ports.begin(); i != ports.end(); ++i) { for (PortSet::iterator i = ports.begin(); i != ports.end(); ++i) {
i->flush_buffers (n_samples); i->flush_buffers (n_samples);
} }
@ -444,6 +500,12 @@ IOPlug::run (samplepos_t start, pframes_t n_samples)
_timing_stats.update (); _timing_stats.update ();
} }
void
IOPlug::reset_input_meters ()
{
g_atomic_int_set (&_reset_meters, 1);
}
bool bool
IOPlug::get_stats (PBD::microseconds_t& min, PBD::microseconds_t& max, double& avg, double& dev) const IOPlug::get_stats (PBD::microseconds_t& min, PBD::microseconds_t& max, double& avg, double& dev) const
{ {

View File

@ -112,6 +112,7 @@ Session::process (pframes_t nframes)
boost::shared_ptr<GraphChain> io_graph_chain = _io_graph_chain[0]; boost::shared_ptr<GraphChain> io_graph_chain = _io_graph_chain[0];
if (io_graph_chain) { if (io_graph_chain) {
PortManager::falloff_cache_calc (nframes, _nominal_sample_rate);
_process_graph->process_io_plugs (io_graph_chain, nframes, 0); _process_graph->process_io_plugs (io_graph_chain, nframes, 0);
io_graph_chain.reset (); /* drop reference */ io_graph_chain.reset (); /* drop reference */
} }