Mercurial > hg > vamp-live-host
changeset 14:bd4589c609c7
* Add silence detection
author | cannam |
---|---|
date | Tue, 12 Dec 2006 12:34:03 +0000 |
parents | 47b0a143db39 |
children | df33703ace3b |
files | host/Processor.cpp host/Processor.h |
diffstat | 2 files changed, 31 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/host/Processor.cpp Tue Dec 12 10:38:55 2006 +0000 +++ b/host/Processor.cpp Tue Dec 12 12:34:03 2006 +0000 @@ -160,6 +160,17 @@ while (toUse >= block) { + bool silentInput = true; + for (size_t s = 0; s < block; ++s) { + for (size_t c = 0; c < ch; ++c) { + if (fabsf(buffers[c][s + off]) > 0.00001) { + silentInput = false; + break; + } + } + if (!silentInput) break; + } + bool haveTransformed = false; for (PluginSet::iterator k = j->second.begin(); @@ -214,9 +225,12 @@ // bool changed = currentState.present; bool changed = false; + if (currentState.silentInput && !silentInput) { + changed = true; + } Vamp::RealTime gap = rt - currentState.laststamp; m_pluginStates[pluginIndex][output] = - OutputState(false, changed, currentState.value, currentState.laststamp, currentState.gap); + OutputState(false, silentInput, changed, currentState.value, currentState.laststamp, currentState.gap); } } @@ -248,9 +262,12 @@ if (fl.empty()) { // bool changed = currentState.present; bool changed = false; + if (currentState.silentInput && !silentInput) { + changed = true; + } Vamp::RealTime gap = rt - currentState.laststamp; m_pluginStates[pluginIndex][output] = - OutputState(false, changed, currentState.value, currentState.laststamp, currentState.gap); + OutputState(false, silentInput, changed, currentState.value, currentState.laststamp, currentState.gap); } else { if (fl[0].hasTimestamp) { @@ -266,13 +283,16 @@ 0.000001) // ) ; + if (currentState.silentInput && !silentInput) { + changed = true; + } if (changed) { std::cerr << "changed: " <<currentState.value << " -> " << value << std::endl; } Vamp::RealTime gap = rt - currentState.laststamp; // std::cerr << "gap = " << gap << std::endl; m_pluginStates[pluginIndex][output] = - OutputState(true, changed, value, rt, gap); + OutputState(true, silentInput, changed, value, rt, gap); } printFeatures(int(plugin), frame[reader], sr, output, fs); @@ -463,6 +483,10 @@ passed = false; + if (state.silentInput) { + break; + } + if (state.changed) { // std::cerr << "State changed with present = " << state.present << ", value = " << state.value << std::endl; oneChanged = true;
--- a/host/Processor.h Tue Dec 12 10:38:55 2006 +0000 +++ b/host/Processor.h Tue Dec 12 12:34:03 2006 +0000 @@ -64,10 +64,11 @@ class OutputState { public: OutputState() : - present(false), changed(false), value(0.f) { } - OutputState(bool p, bool c, float v, Vamp::RealTime s, Vamp::RealTime g) : - present(p), changed(c), value(v), laststamp(s), gap(g) { } + present(false), silentInput(true), changed(false), value(0.f) { } + OutputState(bool p, bool si, bool c, float v, Vamp::RealTime s, Vamp::RealTime g) : + present(p), silentInput(si), changed(c), value(v), laststamp(s), gap(g) { } bool present; + bool silentInput; bool changed; float value; Vamp::RealTime laststamp;