From a2792bd09212eed55bba1aa30dc09043a6955486 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 31 Aug 2014 01:24:57 +0000 Subject: Use float sequences for sample-accurate control ports. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5462 a436a847-0d15-0410-975c-d299462d15a1 --- src/server/BlockImpl.cpp | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'src/server/BlockImpl.cpp') 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 @@ -155,6 +155,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) { @@ -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;*/ -- cgit v1.2.1