13
0

Vapor: add support to trim surround object level

This commit is contained in:
Robin Gareus 2024-01-10 01:31:57 +01:00
parent ee6d46d403
commit a9719f1b35
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 36 additions and 7 deletions

View File

@ -34,6 +34,7 @@
namespace ARDOUR
{
class Amp;
class Session;
class SurroundSend;
class SurroundPannable;
@ -42,7 +43,7 @@ class LV2Plugin;
class LIBARDOUR_API SurroundReturn : public Processor
{
public:
SurroundReturn (Session&);
SurroundReturn (Session&, Route*);
virtual ~SurroundReturn ();
bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
@ -65,6 +66,8 @@ public:
samplecnt_t signal_latency () const;
int set_state (XMLNode const&, int version);
protected:
XMLNode& state () const;
@ -80,6 +83,8 @@ private:
LUFSMeter _lufs_meter;
std::shared_ptr<Amp> _trim;
LV2_Atom_Forge _forge;
uint8_t _atom_buf[8192];
pan_t _current_value[max_object_id][num_pan_parameters];

View File

@ -297,7 +297,7 @@ Route::init ()
if (is_surround_master ()) {
_meter_point = _pending_meter_point = MeterPreFader;
_surround_return.reset (new SurroundReturn (_session));
_surround_return.reset (new SurroundReturn (_session, this));
_surround_return->activate ();
panner_shell()->set_bypassed (true);
@ -3333,6 +3333,11 @@ Route::set_processor_state (XMLNode const& node, int version, XMLProperty const*
_surround_send.reset (new SurroundSend (_session, _mute_master));
_surround_send->set_owner (this);
processor = _surround_send;
} else if (prop->value() == "surreturn") {
if (_surround_return) {
_surround_return->set_state (node, version);
}
return true;
} else {
warning << string_compose(_("unknown Processor type \"%1\"; ignored"), prop->value()) << endmsg;
return false;

View File

@ -17,19 +17,20 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "ardour/surround_return.h"
#include "ardour/amp.h"
#include "ardour/audio_buffer.h"
#include "ardour/lv2_plugin.h"
#include "ardour/route.h"
#include "ardour/session.h"
#include "ardour/surround_pannable.h"
#include "ardour/surround_return.h"
#include "ardour/surround_send.h"
#include "ardour/uri_map.h"
#include "pbd/i18n.h"
using namespace ARDOUR;
SurroundReturn::SurroundReturn (Session& s)
SurroundReturn::SurroundReturn (Session& s, Route* r)
: Processor (s, _("SurrReturn"), Temporal::TimeDomainProvider (Temporal::AudioTime))
, _lufs_meter (s.nominal_sample_rate (), 5)
, _current_n_objects (max_object_id)
@ -49,13 +50,19 @@ SurroundReturn::SurroundReturn (Session& s)
throw ProcessorException (_("Required Atmos/Vapor Processor not found."));
}
ChanCount cca128 (ChanCount (DataType::AUDIO, 128));
_flush.store (0);
_surround_processor->activate ();
_surround_bufs.ensure_buffers (DataType::AUDIO, 128, s.get_block_size ());
_surround_bufs.set_count (ChanCount (DataType::AUDIO, 128));
_surround_bufs.set_count (cca128);
lv2_atom_forge_init (&_forge, URIMap::instance ().urid_map ());
_trim.reset (new Amp (_session, X_("Trim"), r->trim_control(), false));
_trim->configure_io (cca128, cca128);
_trim->activate ();
for (size_t i = 0; i < max_object_id; ++i) {
_current_render_mode[i] = -1;
for (size_t p = 0; p < num_pan_parameters; ++p) {
@ -218,6 +225,10 @@ SurroundReturn::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_
#endif
}
_trim->set_gain_automation_buffer (_session.trim_automation_buffer ());
_trim->setup_gain_automation (start_sample, end_sample, nframes);
_trim->run (_surround_bufs, start_sample, end_sample, speed, nframes, true);
_surround_processor->connect_and_run (_surround_bufs, start_sample, end_sample, speed, _in_map, _out_map, nframes, 0);
BufferSet::iterator i = _surround_bufs.begin (DataType::AUDIO);
@ -372,9 +383,17 @@ SurroundReturn::max_dbtp () const
return _lufs_meter.dbtp ();
}
int
SurroundReturn::set_state (XMLNode const& node, int version)
{
return _trim->set_state (node, version);
}
XMLNode&
SurroundReturn::state () const
{
XMLNode* node = new XMLNode (X_("SurroundReturn"));
return *node;
XMLNode& node (_trim->state ());
node.set_property ("name", "SurrReturn");
node.set_property ("type", "surreturn");
return node;
}