summaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-02-03 22:52:14 +0000
committerDavid Robillard <d@drobilla.net>2013-02-03 22:52:14 +0000
commit69f98d63f5bd22c82208fef5fbc2a61613541bd7 (patch)
treef4c7e33c26ecc44e84ee060d4ae6e6e51e452f19 /src/server
parentc2f0d423f8881376b8e9642a6ab92d9506cdfb41 (diff)
downloadingen-69f98d63f5bd22c82208fef5fbc2a61613541bd7.tar.gz
ingen-69f98d63f5bd22c82208fef5fbc2a61613541bd7.tar.bz2
ingen-69f98d63f5bd22c82208fef5fbc2a61613541bd7.zip
Don't lose peaks for cycles where notifications are not sent.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5046 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server')
-rw-r--r--src/server/PortImpl.cpp32
-rw-r--r--src/server/PortImpl.hpp3
2 files changed, 14 insertions, 21 deletions
diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp
index 0e71de96..f1dacd68 100644
--- a/src/server/PortImpl.cpp
+++ b/src/server/PortImpl.cpp
@@ -58,7 +58,8 @@ PortImpl::PortImpl(BufferFactory& bufs,
, _poly(poly)
, _buffer_size(buffer_size)
, _frames_since_monitor(0)
- , _last_monitor_value(0.0f)
+ , _monitor_value(0.0f)
+ , _peak(0.0f)
, _type(type)
, _buffer_type(buffer_type)
, _value(value)
@@ -148,7 +149,8 @@ PortImpl::activate(BufferFactory& bufs)
const double srate = bufs.engine().driver()->sample_rate();
const uint32_t period = srate / monitor_rate;
_frames_since_monitor = bufs.engine().frand() * period;
- _last_monitor_value = 0.0f;
+ _monitor_value = 0.0f;
+ _peak = 0.0f;
}
void
@@ -161,7 +163,8 @@ PortImpl::deactivate()
}
}
}
- _last_monitor_value = 0.0f;
+ _monitor_value = 0.0f;
+ _peak = 0.0f;
}
Raul::Array<BufferRef>*
@@ -396,7 +399,7 @@ PortImpl::monitor(Context& context, bool send_now)
break;
case PortType::AUDIO:
key = uris.ingen_activity;
- val = std::max(_last_monitor_value, buffer(0)->peak(context));
+ val = _peak = std::max(_peak, buffer(0)->peak(context));
break;
case PortType::CONTROL:
case PortType::CV:
@@ -429,27 +432,16 @@ PortImpl::monitor(Context& context, bool send_now)
}
}
- const uint32_t period = monitor_period(context.engine());
- if (key && val != _last_monitor_value &&
- (send_now || _frames_since_monitor >= period)) {
- // Time to send an update
+ const uint32_t period = monitor_period(context.engine());
+ const bool time_to_send = send_now || _frames_since_monitor >= period;
+ if (time_to_send && key && val != _monitor_value) {
if (context.notify(key, context.start(), this,
sizeof(float), forge.Float, &val)) {
- // Success, update last value
- switch (_type.id()) {
- case PortType::AUDIO:
- _last_monitor_value = 0.0f; // Reset peak
- break;
- case PortType::CONTROL:
- case PortType::CV:
- _last_monitor_value = val; // Store last sent control value
- default:
- break;
- }
-
/* Update frames since last update to conceptually zero, but keep
the remainder to preserve load balancing. */
_frames_since_monitor = _frames_since_monitor % period;
+ _peak = 0.0f;
+ _monitor_value = val;
}
// Otherwise failure, leave old value and try again next time
}
diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp
index 267f9285..f4c80aaf 100644
--- a/src/server/PortImpl.hpp
+++ b/src/server/PortImpl.hpp
@@ -207,7 +207,8 @@ protected:
uint32_t _poly;
uint32_t _buffer_size;
uint32_t _frames_since_monitor;
- float _last_monitor_value;
+ float _monitor_value;
+ float _peak;
PortType _type;
LV2_URID _buffer_type;
Raul::Atom _value;