From ed081d30c860eb8ad3e9d9ec6136422dc2e2d9d0 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 23 May 2012 18:57:14 +0000 Subject: Move mixing stuff to mix.cpp. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4452 a436a847-0d15-0410-975c-d299462d15a1 --- src/server/mix.hpp | 72 +++++++++--------------------------------------------- 1 file changed, 11 insertions(+), 61 deletions(-) (limited to 'src/server/mix.hpp') diff --git a/src/server/mix.hpp b/src/server/mix.hpp index f0a14d79..65dd8de2 100644 --- a/src/server/mix.hpp +++ b/src/server/mix.hpp @@ -17,73 +17,23 @@ #ifndef INGEN_ENGINE_MIX_HPP #define INGEN_ENGINE_MIX_HPP -#include "ingen/shared/URIs.hpp" -#include "raul/log.hpp" - -#include "AudioBuffer.hpp" -#include "Buffer.hpp" -#include "Context.hpp" +#include namespace Ingen { -namespace Server { -inline bool -is_audio(Shared::URIs& uris, LV2_URID type) -{ - return type == uris.atom_Float || type == uris.atom_Sound; -} +namespace Shared { class URIs; } -inline void -mix(Context& context, - Shared::URIs& uris, - Buffer* dst, - Buffer** srcs, - uint32_t num_srcs) -{ - if (num_srcs == 1) { - dst->copy(context, srcs[0]); - } else if (is_audio(uris, dst->type())) { - // Copy the first source - dst->copy(context, srcs[0]); +namespace Server { - // Mix in the rest - for (uint32_t i = 1; i < num_srcs; ++i) { - assert(is_audio(uris, srcs[i]->type())); - ((AudioBuffer*)dst)->accumulate(context, (AudioBuffer*)srcs[i]); - } - } else { - std::cerr << "FIXME: event mix" << std::endl; - } -#if 0 - case PortType::EVENTS: - dst->clear(); - for (uint32_t i = 0; i < num_srcs; ++i) { - assert(srcs[i]->type() == PortType::EVENTS); - srcs[i]->rewind(); - } +class Context; +class Buffer; - while (true) { - const EventBuffer* first = NULL; - for (uint32_t i = 0; i < num_srcs; ++i) { - const EventBuffer* const src = (const EventBuffer*)srcs[i]; - if (src->is_valid()) { - if (!first || src->get_event()->frames < first->get_event()->frames) - first = src; - } - } - if (first) { - const LV2_Event* const ev = first->get_event(); - ((EventBuffer*)dst)->append( - ev->frames, ev->subframes, ev->type, ev->size, - (const uint8_t*)ev + sizeof(LV2_Event)); - first->increment(); - } else { - break; - } - } - dst->rewind(); -#endif -} +void +mix(Context& context, + Shared::URIs& uris, + Buffer* dst, + const Buffer*const* srcs, + uint32_t num_srcs); } // namespace Server } // namespace Ingen -- cgit v1.2.1