From 2e4428bc979b29eaa640144d992b41d6cb4495fb Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 3 May 2015 23:06:21 +0200 Subject: add an API to silence buffers (without session) --- libs/ardour/ardour/port_manager.h | 1 + libs/ardour/port_manager.cc | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/libs/ardour/ardour/port_manager.h b/libs/ardour/ardour/port_manager.h index 6ced0e7dd1..8c55b69022 100644 --- a/libs/ardour/ardour/port_manager.h +++ b/libs/ardour/ardour/port_manager.h @@ -149,6 +149,7 @@ class LIBARDOUR_API PortManager void fade_out (gain_t, gain_t, pframes_t); void silence (pframes_t nframes); + void silence_physical (pframes_t nframes); void check_monitoring (); /** Signal the start of an audio cycle. * This MUST be called before any reading/writing for this cycle. diff --git a/libs/ardour/port_manager.cc b/libs/ardour/port_manager.cc index de78dfd319..37970cc708 100644 --- a/libs/ardour/port_manager.cc +++ b/libs/ardour/port_manager.cc @@ -638,6 +638,45 @@ PortManager::silence (pframes_t nframes) } } +void +PortManager::silence_physical (pframes_t nframes) +{ + std::vector port_names; + if (get_ports("", DataType::AUDIO, IsInput, port_names)) { + for (std::vector::iterator p = port_names.begin(); p != port_names.end(); ++p) { + if (!port_is_mine(*p)) { + continue; + } + PortEngine::PortHandle ph = _backend->get_port_by_name (*p); + if (!ph) { + continue; + } + void *buf = _backend->get_buffer(ph, nframes); + if (!buf) { + continue; + } + memset (buf, 0, sizeof(float) * nframes); + } + } + + if (get_ports("", DataType::MIDI, IsInput, port_names)) { + for (std::vector::iterator p = port_names.begin(); p != port_names.end(); ++p) { + if (!port_is_mine(*p)) { + continue; + } + PortEngine::PortHandle ph = _backend->get_port_by_name (*p); + if (!ph) { + continue; + } + void *buf = _backend->get_buffer(ph, nframes); + if (!buf) { + continue; + } + _backend->midi_clear (buf); + } + } +} + void PortManager::check_monitoring () { -- cgit v1.2.3