From 254b434f0a79fea54bd963e8ff2e845a5b0cd3a6 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 19 Mar 2012 20:16:46 +0000 Subject: Partially functioning communication between Ingen LV2 plugin and UI. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4078 a436a847-0d15-0410-975c-d299462d15a1 --- src/server/mix.hpp | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'src/server/mix.hpp') diff --git a/src/server/mix.hpp b/src/server/mix.hpp index 21040c52..54f80dfc 100644 --- a/src/server/mix.hpp +++ b/src/server/mix.hpp @@ -20,36 +20,45 @@ #include +#include "ingen/shared/URIs.hpp" #include "raul/log.hpp" #include "Buffer.hpp" #include "Context.hpp" -#include "PortType.hpp" using namespace Raul; namespace Ingen { namespace Server { +inline bool +is_audio(Shared::URIs& uris, LV2_URID type) +{ + return type == uris.atom_Float || type == uris.atom_Sound; +} + inline void -mix(Context& context, Buffer* dst, const boost::intrusive_ptr* srcs, uint32_t num_srcs) +mix(Context& context, + Shared::URIs& uris, + Buffer* dst, + const boost::intrusive_ptr* srcs, + uint32_t num_srcs) { - using Ingen::PortType; - switch (dst->type().symbol()) { - case PortType::AUDIO: - case PortType::CONTROL: - case PortType::CV: + if (num_srcs == 1) { + dst->copy(context, srcs[0].get()); + } else if (is_audio(uris, dst->type())) { // Copy the first source dst->copy(context, srcs[0].get()); // Mix in the rest for (uint32_t i = 1; i < num_srcs; ++i) { - assert(srcs[i]->type() == PortType::AUDIO || - srcs[i]->type() == PortType::CONTROL || - srcs[i]->type() == PortType::CV); + assert(is_audio(uris, srcs[i]->type())); ((AudioBuffer*)dst)->accumulate(context, (AudioBuffer*)srcs[i].get()); } - break; + } else { + std::cerr << "FIXME: event mix" << std::endl; + } +#if 0 case PortType::EVENTS: dst->clear(); for (uint32_t i = 0; i < num_srcs; ++i) { @@ -77,14 +86,7 @@ mix(Context& context, Buffer* dst, const boost::intrusive_ptr* srcs, uin } } dst->rewind(); - break; - default: - if (num_srcs == 1) - dst->copy(context, srcs[0].get()); - else - error << "Mix of unsupported buffer types" << std::endl; - return; - } +#endif } } // namespace Server -- cgit v1.2.1