13
0

add an API to silence buffers (without session)

This commit is contained in:
Robin Gareus 2015-05-03 23:06:21 +02:00
parent 56cc3e2407
commit 2e4428bc97
2 changed files with 40 additions and 0 deletions

View File

@ -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.

View File

@ -638,6 +638,45 @@ PortManager::silence (pframes_t nframes)
}
}
void
PortManager::silence_physical (pframes_t nframes)
{
std::vector<std::string> port_names;
if (get_ports("", DataType::AUDIO, IsInput, port_names)) {
for (std::vector<std::string>::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<std::string>::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 ()
{