1
/******************************************************************************
2
* Copyright © 2012-2014 Institut für Nachrichtentechnik, Universität Rostock *
3
* Copyright © 2006-2012 Quality & Usability Lab, *
4
* Telekom Innovation Laboratories, TU Berlin *
6
* This file is part of the Audio Processing Framework (APF). *
8
* The APF is free software: you can redistribute it and/or modify it under *
9
* the terms of the GNU General Public License as published by the Free *
10
* Software Foundation, either version 3 of the License, or (at your option) *
11
* any later version. *
13
* The APF is distributed in the hope that it will be useful, but WITHOUT ANY *
14
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *
15
* FOR A PARTICULAR PURPOSE. *
16
* See the GNU General Public License for more details. *
18
* You should have received a copy of the GNU General Public License along *
19
* with this program. If not, see <http://www.gnu.org/licenses/>. *
21
* http://AudioProcessingFramework.github.com *
22
******************************************************************************/
24
// A small example of the MimoProcessor with varying JACK input ports.
25
// This is a stand-alone program.
27
#include "apf/mimoprocessor.h"
28
#include "apf/combine_channels.h" // for apf::CombineChannels
29
#include "apf/jack_policy.h"
30
#include "apf/posix_thread_policy.h"
32
class MyProcessor : public apf::MimoProcessor<MyProcessor
34
, apf::posix_thread_policy>
37
using Input = MimoProcessorBase::DefaultInput;
39
class Output : public MimoProcessorBase::DefaultOutput
42
explicit Output(const Params& p)
43
: MimoProcessorBase::DefaultOutput(p)
44
, _combiner(this->parent.get_input_list(), *this)
47
APF_PROCESS(Output, MimoProcessorBase::DefaultOutput)
49
float weight = 1.0f/static_cast<float>(
50
this->parent.get_input_list().size());
51
_combiner.process(simple_predicate(weight));
55
class simple_predicate
58
explicit simple_predicate(float weight) : _weight(weight) {}
60
// trivial, all inputs are used; no crossfade/interpolation
61
apf::CombineChannelsResult::type select(const Input&)
63
return apf::CombineChannelsResult::constant;
66
float operator()(float in) { return in * _weight; }
72
apf::CombineChannels<rtlist_proxy<Input>, Output> _combiner;
90
std::vector<MyProcessor::Input*> inputs;
92
for (int i = 1; i <= in_channels; ++i)
94
MyProcessor::Input::Params p;
96
inputs.push_back(engine.add(p));
102
// remove the inputs one by one ...
103
while (inputs.begin() != inputs.end())
105
engine.rem(inputs.front());
106
engine.wait_for_rt_thread();
107
inputs.erase(inputs.begin());
116
// Settings for Vim (http://www.vim.org/), please do not remove:
117
// vim:softtabstop=2:shiftwidth=2:expandtab:textwidth=80:cindent