summaryrefslogtreecommitdiffstats
path: root/src/server/BlockImpl.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-08-31 01:24:57 +0000
committerDavid Robillard <d@drobilla.net>2014-08-31 01:24:57 +0000
commita2792bd09212eed55bba1aa30dc09043a6955486 (patch)
treed4262f760d4522bc6f1c99778987aada332b9e7e /src/server/BlockImpl.cpp
parente3ecb2b439bd03d27b5e11efe430c24f0ebe6283 (diff)
downloadingen-a2792bd09212eed55bba1aa30dc09043a6955486.tar.gz
ingen-a2792bd09212eed55bba1aa30dc09043a6955486.tar.bz2
ingen-a2792bd09212eed55bba1aa30dc09043a6955486.zip
Use float sequences for sample-accurate control ports.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5462 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server/BlockImpl.cpp')
-rw-r--r--src/server/BlockImpl.cpp46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/server/BlockImpl.cpp b/src/server/BlockImpl.cpp
index 0cae55a2..069ecdfa 100644
--- a/src/server/BlockImpl.cpp
+++ b/src/server/BlockImpl.cpp
@@ -156,6 +156,45 @@ BlockImpl::pre_process(ProcessContext& context)
}
void
+BlockImpl::process(ProcessContext& context)
+{
+ pre_process(context);
+
+ ProcessContext subcontext(context);
+ for (SampleCount offset = 0; offset < context.nframes();) {
+ // Find earliest offset of a value change
+ SampleCount chunk_end = context.nframes();
+ for (uint32_t i = 0; _ports && i < _ports->size(); ++i) {
+ PortImpl* const port = _ports->at(i);
+ if (port->type() == PortType::CONTROL && port->is_input()) {
+ const SampleCount o = port->next_value_offset(
+ offset, context.nframes());
+ if (o < chunk_end) {
+ chunk_end = o;
+ }
+ }
+ }
+
+ // Slice context into a chunk from now until the next change
+ subcontext.slice(offset, chunk_end - offset);
+
+ // Prepare port buffers for reading, converting/mixing if necessary
+ for (uint32_t i = 0; _ports && i < _ports->size(); ++i) {
+ _ports->at(i)->connect_buffers(offset);
+ _ports->at(i)->pre_run(subcontext);
+ }
+
+ // Run the chunk
+ run(subcontext);
+
+ offset = chunk_end;
+ subcontext.slice(offset, chunk_end - offset);
+ }
+
+ post_process(context);
+}
+
+void
BlockImpl::post_process(ProcessContext& context)
{
// Write output ports
@@ -165,9 +204,10 @@ BlockImpl::post_process(ProcessContext& context)
}
void
-BlockImpl::set_port_buffer(uint32_t voice,
- uint32_t port_num,
- BufferRef buf)
+BlockImpl::set_port_buffer(uint32_t voice,
+ uint32_t port_num,
+ BufferRef buf,
+ SampleCount offset)
{
/*std::cout << path() << " set port " << port_num << " voice " << voice
<< " buffer " << buf << " offset " << offset << std::endl;*/