From 4fe9d9967427a4bc060a4488c26f139bd8469513 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 4 Feb 2022 13:19:47 +0100 Subject: [PATCH] Auditioner: add API for UI to run the synth (idle) This allows the synth to process injected out-of-band MIDI data, such as Program/Patch Changes while audition is inactive. --- libs/ardour/ardour/auditioner.h | 2 ++ libs/ardour/auditioner.cc | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/libs/ardour/ardour/auditioner.h b/libs/ardour/ardour/auditioner.h index 4bbcf5e92f..f1fc8b4c3a 100644 --- a/libs/ardour/ardour/auditioner.h +++ b/libs/ardour/ardour/auditioner.h @@ -57,6 +57,8 @@ public: sampleoffset_t seek_sample() const { return _seeking ? _seek_sample : -1;} void seek_response(sampleoffset_t pos); + void idle_synth_update (); + MonitorState monitoring_state () const; bool needs_monitor() const { return via_monitor; } diff --git a/libs/ardour/auditioner.cc b/libs/ardour/auditioner.cc index e9613e7e23..391309a74a 100644 --- a/libs/ardour/auditioner.cc +++ b/libs/ardour/auditioner.cc @@ -551,6 +551,22 @@ Auditioner::seek_response (sampleoffset_t pos) { } } +void +Auditioner::idle_synth_update () +{ + if (auditioning() || !asynth) { + return; + } + auto pi = boost::dynamic_pointer_cast (asynth); + + /* Note: calling thread must have process buffers */ + BufferSet bufs; + samplepos_t start = 0; + pframes_t n_samples = 16; + /* MIDI buffers need to be able to hold patch/pgm change messages. (16 bytes + msg-size) per event */ + bufs.ensure_buffers (max (asynth->input_streams (), asynth->output_streams ()), std::max (1024, n_samples)); + pi->run (bufs, start, start + n_samples, 1.0, n_samples, false); +} void Auditioner::output_changed (IOChange change, void* /*src*/)